package cn.com.bluemoon.daps.system.service.impl;

import cn.com.bluemoon.daps.api.model.RemoteDataModelService;
import cn.com.bluemoon.daps.api.model.RemoteDataModelTableService;
import cn.com.bluemoon.daps.common.domain.ResultBean;
import cn.com.bluemoon.daps.system.service.BizLineDeletePredicate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 模型模块中关联业务线的删除前判断
 *
 * @author Jarod.Kong
 */
//@Service
@Slf4j
public class ModelModuleBizLineDeletePredicate implements BizLineDeletePredicate {

    @Resource
    RemoteDataModelService remoteDataModelService;

    @Override
    public Result<Integer> predicate(Integer bizLineId) {
        // 2021/9/27  需要立航完善 返回规则，参考StandardModuleTopicCategoryDeletePredicate
        ResultBean<Boolean> bizLineModel = remoteDataModelService.getBizLineModel(bizLineId);
        Boolean flag = bizLineModel.getCode() == 200 && bizLineModel.getContent() ? bizLineModel.getContent() : false;
        String message = flag ? "" : "模型已引用，不可删除";
        return Result.<Integer>builder().canDelete(flag).key(bizLineId).message(message).build();
    }
}
